Java Agent hanging client
Posted by ~Vijay Brefreegenetsi on 25.Jun.03 at 09:41 PM using a Web browser Category : Applications Development Release: 6.0.1 Platform: Windows 2000
Hi,
I am very new to Java. I have written an Agent that hangs the client. I am attempting to display a dialog box. The dialog box appears, however, the client then hangs.
Any ideas what could be causing the hang?
Here is the code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import lotus.domino.*;
public class ExUserClassify extends AgentBase
{
// Construction
// Attributes
Session curSession;
AgentContext curAgentContext;
Database curDatabase;
Database colDatabase;
Document curDocument;
DocumentCollection curCollection;
String strFileName;
// Operations
public void NotesMain()
{
int i;
try
{
// Get current Session
curSession = getSession();
// Get current AgentContext
curAgentContext = curSession.getAgentContext();
DlgSetup sdSetup = new DlgSetup();
}
catch(Exception e)
{
e.printStackTrace();
}
}
// Implementation
}
class DlgSetup
{
DlgSetup()
{
dialog = new CodeChooser();
dialog.showDialog(null, "Select Classification Code");
}
private CodeChooser dialog = null;
}
class CodeChooser extends JPanel
{
CodeChooser()
{
setLayout(new BorderLayout());
// Construct the panel with our controls.
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
label = new JLabel("Select code:");
cb = new JComboBox();
cb.setEditable(true);
// For now, just add items.
cb.addItem("Gwynn");
cb.addItem("McGwire");
cb.addItem("Bonds");
cb.addItem("Ruth");
panel.add(label);
panel.add(cb);
add(panel, BorderLayout.CENTER);
// Create the Ok and Cancel buttons.
JButton okButton = new JButton("Ok");
okButton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
ok = true;
dialog.setVisible(false);
}
}
);
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
dialog.setVisible(false);
}
}
);
// Add buttons to another panel on the southern border.
JPanel buttonPanel = new JPanel();
buttonPanel.add(okButton);
buttonPanel.add(cancelButton);
add(buttonPanel, BorderLayout.SOUTH);
}
public boolean showDialog(Component parent, String title)
{
ok = false;
// Locate the owner frame.
Frame owner = null;
if (parent instanceof Frame)
owner = (Frame)parent;
else
owner = (Frame)SwingUtilities.getAncestorOfClass(Frame.class, parent);
owner = null;
dialog = new JDialog(owner, true);
dialog.getContentPane().add(this);
dialog.pack();
dialog.setTitle(title);
dialog.show();
return ok;
}
private JLabel label;
private JComboBox cb;
private boolean ok;
private JDialog dialog;
}
Any help on this is much appreciated. I have spent a long time trying to figure out what's going on.
Thanks,
- Michael